﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using ShredTheLog.Api;
using System.Windows.Input;
using ShredTheLog.Common.MVVM;
using System.Net;
using ShredTheLog.Model;
using ShredTheLog.Api.DataContracts.TextChat;
using System.Diagnostics.Contracts;
using ShredTheLog.Common;
using ShredTheLog.Api.DataContracts;
using ShredTheLog.Views;
using ShredTheLog.ViewModels;
using System.Diagnostics;
using System.Windows.Media;
using ShredTheLog.Controls;
using System.Windows.Threading;

namespace ShredTheLog.Plugins
{
    [Export(typeof(ICommandListItem))]
    [MenuCommandMetadata(Menu = Menus.View, Order = 0, Group = null)]
    [Export(typeof(IGoToTextChatCommand))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public sealed class GoToTextChatCommand : DelegateCommand, IUiCommand, IGoToTextChatCommand
    {
        [Import]
        private IShredServices ShredServices { get; set; }

        [Import]
        private IShowLogInDialogCommand ShowLogInDialogCommand { get; set; }

        [Import]
        private IConnectionSettingsSection ConnectionSettings { get; set; }

        public GoToTextChatCommand()
        {
            _executeMethod =
                () =>
                {
                    if (Completed != null)
                        Completed(this, EventArgs.Empty);
                };
        }

        public string Name { get { return ShredServices.GetLocalizedString("s_Menu_TextChat"); } }
        public ImageSource Image { get { return null; } }

        public event EventHandler Completed;
    }

    [Export(typeof(ICommandListItem))]
    [MenuCommandMetadata(Menu = Menus.View, Order = 100, Group = null)]
    [Export(typeof(IGoToContactListCommand))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public sealed class GoToContactListCommand : DelegateCommand, IUiCommand, IGoToContactListCommand
    {
        [Import]
        private IShredServices ShredServices { get; set; }

        [Import]
        private IShowLogInDialogCommand ShowLogInDialogCommand { get; set; }

        public GoToContactListCommand()
        {
            _executeMethod =
                () =>
                {
                    if (Completed != null)
                        Completed(this, EventArgs.Empty);
                };
            _canExecuteMethod = () => ShowLogInDialogCommand.Credentials != null;
        }

        public string Name { get { return ShredServices.GetLocalizedString("s_Menu_ContactList"); } }
        public ImageSource Image { get { return null; } }

        public event EventHandler Completed;
    }

    [Export(typeof(ICommandListItem))]
    [MenuCommandMetadata(Menu = Menus.View, Order = 200, Group = null)]
    [Export(typeof(IGoToUserSearchCommand))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public sealed class GoToUserSearchCommand : DelegateCommand, IUiCommand, IGoToUserSearchCommand
    {
        [Import]
        private IShredServices ShredServices { get; set; }

        public GoToUserSearchCommand()
        {
            _executeMethod =
                () =>
                {
                    if (Completed != null)
                        Completed(this, EventArgs.Empty);
                };

        }

        public string Name { get { return ShredServices.GetLocalizedString("s_UserSearch"); } }
        public ImageSource Image { get { return null; } }

        public event EventHandler Completed;
    }

    [Export(typeof(ICommandListItem))]
    [MenuCommandMetadata(Menu = Menus.View, Order = 500, Group = null)]
    [Export(typeof(IGoToMailboxCommand))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public sealed class GoToMailboxCommand : DelegateCommand, IUiCommand, IGoToMailboxCommand
    {
        [Import]
        private IShredServices ShredServices { get; set; }

        public GoToMailboxCommand()
            : base(() => { throw new NotImplementedException(); }, () => false)
        {
        }

        public string Name { get { return ShredServices.GetLocalizedString("s_Mailbox"); } }
        public ImageSource Image { get { return null; } }
    }

    [Export(typeof(ICommandListItem))]
    [MenuCommandMetadata(Menu = Menus.View, Order = 600, Group = null)]
    [Export(typeof(IGoToVoiceChatCommand))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public sealed class GoToVoiceChatCommand : DelegateCommand, IUiCommand, IGoToVoiceChatCommand
    {
        [Import]
        private IShredServices ShredServices { get; set; }

        public GoToVoiceChatCommand()
            : base(() => { throw new NotImplementedException(); }, () => false)
        {
        }

        public string Name { get { return ShredServices.GetLocalizedString("s_VoiceChat"); } }
        public ImageSource Image { get { return null; } }
    }
}
